package com.org.controller.dev;

import com.org.core.annotation.SerializedField;
import com.org.core.current.UserService;
import com.org.entity.base.PageRequest;
import com.org.entity.base.PageResult;
import com.org.entity.current.CurrentUser;
import com.org.entity.dev.DevDataBackupConfig;
import com.org.service.dev.DevDataBackupConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value="api/dev/data/backup/config")
@Api(tags={"DevDataBackupConfigController"},description="数据库备份服务接口")
public class DevDataBackupConfigController {

    @Autowired
    private DevDataBackupConfigService devDataBackupConfigService;
    @Autowired
    private UserService userService;
    
    @RequestMapping(method = RequestMethod.POST)
    @ApiOperation(value="新增记录信息",notes="新增记录信息")
    @SerializedField(moduleName = "新增")
    public int addDevDataBackupConfigInfo(@RequestBody @Validated DevDataBackupConfig devDataBackupConfig) {
        CurrentUser currentUser = userService.getCurrentUser();
        devDataBackupConfig.setAddUser(currentUser.getUserId());
        return devDataBackupConfigService.addDevDataBackupConfigInfo(devDataBackupConfig);
    }
    
    @RequestMapping(method = RequestMethod.PUT)
    @ApiOperation(value = "修改记录信息", notes = "修改记录信息")
    @SerializedField(moduleName = "修改")
    public int updateDevDataBackupConfigInfo(@RequestBody @Validated DevDataBackupConfig devDataBackupConfig) {
        return devDataBackupConfigService.updateDevDataBackupConfigInfo(devDataBackupConfig);
    }
    
    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "根据主键id删除指定", notes = "根据主键id删除指定")
    @SerializedField(moduleName = "删除")
    public int delDevDataBackupConfigInfo(@PathVariable(value = "id") String id) {
        return devDataBackupConfigService.delDevDataBackupConfigInfo(id);
    }
    
    @RequestMapping(method = RequestMethod.DELETE)
    @ApiOperation(value = "根据ids批量删除列表信息", notes = "根据ids批量删除列表信息")
    @SerializedField(moduleName = "批量删除")
    public int delDevDataBackupConfigList(String ids) {
        return devDataBackupConfigService.delDevDataBackupConfigList(ids);
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据主键id获取详情", notes = "根据主键id获取详情")
    @SerializedField(moduleName = "获取")
    public DevDataBackupConfig getDevDataBackupConfigInfo(@PathVariable(value = "id") String id) {
        return devDataBackupConfigService.getDevDataBackupConfigInfo(id);
    }

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "获取列表", notes = "获取列表")
    @SerializedField(moduleName = "获取列表")
    public List<DevDataBackupConfig> getDevDataBackupConfigList(@RequestParam(value = "keyword", required = false) String keyword) {
        return devDataBackupConfigService.getDevDataBackupConfigList(keyword);
    }

    @RequestMapping(value = "/page/list", method = RequestMethod.GET)
    @ApiOperation(value = "获取分页列表", notes = "获取分页列表")
    @SerializedField(moduleName = "获取列表")
    public PageResult<DevDataBackupConfig> getDevDataBackupConfigPageList(@RequestParam(value = "keyword", required = false) String keyword, PageRequest pageRequest) {
        return devDataBackupConfigService.getDevDataBackupConfigPageList(keyword, pageRequest);
    }
}


